﻿app.controller('menuController', ['$scope', 'menuService', '$ocLazyLoad', 'tabService', function ($scope, menuService, $ocLazyLoad, tabService) {
    $scope.menus = menuService.menus;
    // lists//
    $scope.lists=[{
        name:"小王",
        sex:'mm',
        age:22,
        come:"yuan",
        id:120
        },
        {
            name:"小王",
            sex:'gg',
            age:22,
            come:"yuan",
            id:120
        },{
            name:"小王",
            age:22,
            sex:'mm',
            come:"zhen",
            id:120
        },


    ]
    $scope.click = function (elem) {
        //左边选中的菜单
        var selectMenu = menuService.selectMenuByID(elem.menu.id);
        var templateurlstr = menuService.GetTemplateUrlString(selectMenu.key);

        if (tabService.tabs.length > 0) {
            var parenttab;
            if (selectMenu.parent) {
                parenttab = tabService.getTabByMenuID(selectMenu.parent.id);
            }

            var selectTab = tabService.selectTabByMenuID(selectMenu.id);

            if (selectTab == null) {
                var item1 = new tabService.tabItem(selectMenu.key, selectMenu.value, true, selectMenu.isclose, selectMenu.id, parenttab, true, templateurlstr);
                tabService.addTab(item1);
            }
        } else if (selectMenu.ishide == false) {
            var item1 = new tabService.tabItem(selectMenu.key, selectMenu.value, true, selectMenu.isclose, selectMenu.id, null, true, templateurlstr);
            tabService.addTab(item1);
        }
    }
}])

//菜单服务，主要做菜单数据的获取，变更等操作。
app.controller('tabController', ['$scope', 'tabService', 'menuService', '$location', '$state', '$cookieStore', '$element', '$timeout', function ($scope, tabService, menuService, $location, $state, $cookieStore, $element, $timeout) {
    var selectMenu;

    console.log(menuService)
    for (var i = 0; i < menuService.menus.length; i++) {
        if (menuService.menus[i].isdefault && menuService.menus[i].ishide == false || menuService.menus[i].isdefaultPath == true) {
            selectMenu = menuService.menus[i];
            if (tabService.tabs.length > 0) {
                var selectTab = tabService.getTabByKey(menuService.menus[i].key)
                if (selectTab == null) {
                    var templateurlstr = menuService.GetTemplateUrlString(selectMenu.key);
                    var item1 = new tabService.tabItem(menuService.menus[i].key, menuService.menus[i].value, true, menuService.menus[i].isclose, menuService.menus[i].id, null, false, templateurlstr);
                    tabService.addTab(item1);
                }
            } else {
                var templateurlstr = menuService.GetTemplateUrlString(selectMenu.key);
                var item1 = new tabService.tabItem(menuService.menus[i].key, menuService.menus[i].value, true, menuService.menus[i].isclose, menuService.menus[i].id, null, true, templateurlstr);
                tabService.addTab(item1);
            }
        }
    }

    $scope.select = function (selectedTab) {
        console.log(selectedTab)
        var url = $location.path()
        var urlPath = tabService.GetUrlString(selectedTab.key, true);

        if (selectedTab) {
            selectMenu = menuService.selectMenuByID(selectedTab.menuid);
        }

        if (url != urlPath) {
            $state.go(selectedTab.key, selectedTab.params);
        }
    }

    $scope.close = function (selectedTab) {
        //var index = tabService.tabs.indexOf(selectedTab);
        //tabService.removeTab(index);
    }
    if ($cookieStore.get("zdxtToken") == null) {
        $state.go("access.signin");
        return;
    }
    tabService.selectTabByID(1);
    $scope.tabs = tabService.tabs;
}]);

app.controller('DatepickerCtrl', ['$scope', function ($scope) {
    $scope.initDate = new Date('2016-10-20');
    $scope.formats = ['dd-MMMM-yyyy', 'yyyy-MM-dd', 'yyyy/MM/dd', 'dd.MM.yyyy', 'shortDate'];
    $scope.format = $scope.formats[1];

    $scope.today = function () {
        var d = new Date();
        var year = d.getFullYear();
        var month = d.getMonth() + 1;
        if (month < 10) {
            month = '0' + month;
        }
        var date = d.getDate();
        if (date < 10) {
            date = '0' + date;
        }
        switch ($scope.format) {
            case 'yyyy-MM-dd':
                $scope.dt = year + '-' + month + '-' + date;
                break;
            case 'yyyy/MM/dd':
                $scope.dt = year + '/' + month + '/' + date;
                break;
            case 'dd.MM.yyyy':
                $scope.dt = date + '.' + month + '.' + year;
                break;
            default:
                $scope.dt = new Date();
                break;
        }
    };
    $scope.today();

    $scope.clear = function () {
        $scope.dt = null;
    };

    // Disable weekend selection
    $scope.disabled = function (date, mode) {
        return (mode === 'day' && (date.getDay() === 0 || date.getDay() === 6));
    };

    $scope.toggleMin = function () {
        $scope.minDate = $scope.minDate ? null : new Date();
    };
    $scope.toggleMin();

    $scope.open = function ($event) {
        $event.preventDefault();
        $event.stopPropagation();

        $scope.opened = true;
    };

    $scope.dateOptions = {
        formatYear: 'yyyy',
        startingDay: 1,
        class: 'datepicker'
    };
}]);
app.controller('TimepickerCtrl', ['$scope', function ($scope) {
    $scope.mytime = new Date();

    $scope.hstep = 1;
    $scope.mstep = 15;

    $scope.options = {
        hstep: [1, 2, 3],
        mstep: [1, 5, 10, 15, 25, 30]
    };

    $scope.ismeridian = true;
    $scope.toggleMode = function () {
        $scope.ismeridian = !$scope.ismeridian;
    };

    $scope.update = function () {
        var d = new Date();
        d.setHours(14);
        d.setMinutes(0);
        $scope.mytime = d;
    };

    $scope.changed = function () {
        //console.log('Time changed to: ' + $scope.mytime);
    };

    $scope.clear = function () {
        $scope.mytime = null;
    };
}])
app.controller('ModalInstanceCtrl', function ($scope, $modalInstance, content, title, okCancel, deferred) {
    $scope.Content = content;
    $scope.Title = title;
    $scope.OkCancel = okCancel;

    $scope.ok = function () {
        $modalInstance.close('ok');
        deferred.resolve();
    };

    $scope.cancel = function () {
        $modalInstance.dismiss('cancel');
        deferred.reject();
    };
});
app.controller('TypeaheadDemoCtrl', ['$scope', '$http', function ($scope, $http) {
    $scope.selected = undefined;
    $scope.states = ['Alabama', 'Alaska', 'Arizona', 'Arkansas', 'California', 'Colorado', 'Connecticut', 'Delaware', 'Florida', 'Georgia', 'Hawaii', 'Idaho', 'Illinois', 'Indiana', 'Iowa', 'Kansas', 'Kentucky', 'Louisiana', 'Maine', 'Maryland', 'Massachusetts', 'Michigan', 'Minnesota', 'Mississippi', 'Missouri', 'Montana', 'Nebraska', 'Nevada', 'New Hampshire', 'New Jersey', 'New Mexico', 'New York', 'North Dakota', 'North Carolina', 'Ohio', 'Oklahoma', 'Oregon', 'Pennsylvania', 'Rhode Island', 'South Carolina', 'South Dakota', 'Tennessee', 'Texas', 'Utah', 'Vermont', 'Virginia', 'Washington', 'West Virginia', 'Wisconsin', 'Wyoming'];
    // Any function returning a promise object can be used to load values asynchronously
    $scope.getLocation = function (val) {
        return $http.get('http://maps.googleapis.com/maps/api/geocode/json', {
            params: {
                address: val,
                sensor: false
            }
        }).then(function (res) {
            var addresses = [];
            angular.forEach(res.data.results, function (item) {
                addresses.push(item.formatted_address);
            });
            return addresses;
        });
    };
}]);
app.controller('indexController', function ($scope, $modal, $log, $interval, $timeout, $element, tabService, dicSet) {
    // $scope.myTable = {};
    // var selected = new Array();
    // var dtOrder;
    // $scope.open = function (type, size) {
    //     if (type == 'edit' && (selected.length > 1 || selected.length == 0)) {
    //         angular.alert('请选中一个项目进行编辑！');
    //         return;
    //     }
    //     dtOrder = $scope.myTable.api().order();
    //     var modalInstance = $modal.open({
    //         templateUrl: 'template/dictsystemadd.html',
    //         controller: 'DicSetAddCtrl',
    //         size: 'lg',
    //         backdrop: 'static',
    //         resolve: {
    //             type: function () {
    //                 return type;
    //             },
    //             selected: function () {
    //                 return selected;
    //             },
    //             deps: ['$ocLazyLoad',
    //                 function ($ocLazyLoad) {
    //                     return $ocLazyLoad.load(['js/controllers/dictsystemadd.js']);
    //                 }]
    //         }
    //     });
    //
    //     modalInstance.result.then(function (item) {
    //         switch (type) {
    //             case 'edit':
    //                 dicSet.Edit(item).success(function (data, header, config, status) {
    //                     //dtReload();
    //                     //alert('success');
    //                     init();
    //                 }).error(function (data, header, config, status) {
    //                     angular.alert('操作失败！');
    //                 });
    //                 break;
    //             default:
    //                 dicSet.Add(item).success(function (data, header, config, status) {
    //                     //item.SerialNo = data;
    //                     //dtReload(OperationMode.Add, item);
    //                     //alert('success');
    //                     init();
    //                     if (dtOrder) {
    //                         $scope.myTable.api().order(dtOrder).draw();
    //                         dtOrder = null;
    //                     }
    //                 }).error(function (data, header, config, status) {
    //                     angular.alert('操作失败！');
    //                 });
    //                 break;
    //         }
    //         $log.info('OK at: ' + new Date());
    //     }, function (item) {
    //         if (item) {
    //             init();
    //         }
    //         $log.info('Modal dismissed at: ' + new Date());
    //     });
    // };
    //
    //
    // if (typeof OperationMode == 'undefined') {
    //     var OperationMode = {
    //         Search: 0,
    //         Add: 1,
    //         Edit: 2,
    //         Delete: 3
    //     }
    // }
    //
    // var dtReload = function (operationMode, item) {
    //     var existing = $scope.dtData.slice();
    //     switch (operationMode) {
    //         case OperationMode.Add:
    //             if (item) {
    //                 existing.push(item);
    //             }
    //             break;
    //         case OperationMode.Delete:
    //             if (item) {
    //                 existing.splice($.inArray(item, existing), 1);
    //             }
    //             break;
    //         default:
    //             break;
    //     }
    //     $scope.dtData = existing;
    // };
    //
    // $scope.remove = function () {
    //     if (selected.length == 0) {
    //         angular.alert('请选中项目后再删除！');
    //         return;
    //     }
    //     angular.alert('确定删除选中的项目吗？', null, true).ok(function () {
    //         dicSet.Delete(selected[0].SerialNo).success(function (data, header, config, status) {
    //             //dtReload(OperationMode.Delete, selected[0]);
    //             //alert('success');
    //             init();
    //         }).error(function (data, header, config, status) {
    //             angular.alert('操作失败！');
    //         });
    //     });
    // }
    // //var a = $('#table1').dataTable().fnSettings();
    //
    // $scope.rowCallback = function (nRow, aData, iDisplayIndex, iDisplayIndexFull) {
    //     angular.element(nRow).unbind('click');
    //     angular.element(nRow).bind('click', function () {
    //         $scope.someClickHandler(angular.element(nRow), aData);
    //     });
    //     return nRow;
    // };
    //
    // $scope.someClickHandler = function (row, info) {
    //     if (row.hasClass('selected')) {
    //         selected.splice($.inArray(info, selected), 1);
    //     } else {
    //         selected.length = 0;
    //         selected.push(info);
    //         row.parent().find(".selected").toggleClass('selected');
    //     }
    //     row.toggleClass('selected');
    // };
    //
    // $scope.columnDefs = [
    //     { data: 'SerialNo',  /* width: '10%',*/ targets: 0 },
    //     //{ data: null, "targets": 0 },
    //     { data: 'Value', targets: 1 },
    //     { data: 'EnglishName', targets: 2 },
    //     { data: 'AbbInfo.Name', targets: 3 },
    //     { data: 'AbbInfo.Code', targets: 4 },
    //     { data: 'InputCode', targets: 5 },
    //     { data: 'Description', targets: 6 }
    // ];
    //
    // $scope.dtOptions = {
    //     order: [[0, 'desc']],
    //     info: true,
    //     ordering: false,
    //     paging: true,
    //     processing: false,
    //     searching: false,
    //     scrollY: '100px',
    //     autoWidth: false,
    //     stateSave: false,
    //     stateDuration: 60 * 60 * 24,
    //     // lengthMenu: [14, 50, 100],
    //     pagingType: 'full_numbers',
    //     search: {
    //         caseInsensitive: true,
    //         regex: true,
    //         smart: false
    //     },
    //     language: {
    //         url: 'vendor/jquery/datatables/Chinese.json'
    //     },
    //     drawCallback: function () {
    //         var selectedTab = tabService.getTabByMenuID();
    //         var contentElement = angular.element("#" + "myMenu" + selectedTab.id).find(".contentElement");
    //         setAutoTableHeadClass(contentElement);
    //
    //         if (this.api().column(0).nodes() == null) {
    //             return;
    //         }
    //         this.api().column(0).nodes().each(function (cell, i) {
    //             cell.innerHTML = i + 1;
    //         });
    //
    //     }
    // };
    //
    // var init = function () {
    //     dicSet.GetAll().success(function (data, header, config, status) {
    //         //响应成功
    //
    //         $scope.dtData = data;
    //         console.log($scope.dtData)
    //     }).error(function (data, header, config, status) {
    //         //处理响应失败
    //         angular.alert('操作失败！');
    //         $log.log(status);
    //     }).finally(function () {
    //         //hideThead();
    //     })
    // };
    //  // angular.element('table').resize()
    // init();
    // function hideThead() {
    //     $timeout(function () {
    //         var selectedTab = tabService.getTabByMenuID();
    //         var contentElement = angular.element("#" + "myMenu" + selectedTab.id).find(".contentElement");
    //         setAutoTableHead(contentElement);
    //         setAutoTableHeight(contentElement);
    //         // contentElement.resize()
    //     },500)
    //
    //     //var timeMethod = $interval(function () {
    //     //    var selectedTab = tabService.getTabByMenuID();
    //     //    var contentElement = angular.element("#" + "myMenu" + selectedTab.id).find(".contentElement");
    //     //    setAutoTableHead(contentElement);
    //     //    setAutoTableHeight(contentElement);
    //     //}, 1000);
    //     //$scope.$on('$destroy', function () {
    //     //    $interval.cancel(timeMethod);
    //     //});
    // }
    // $scope.all=[{
    //     day:'4-1',
    //     week:'周一',
    //     num:'20'
    // },{
    //     day:'4-1',
    //     week:'周一',
    //     num:'20'
    // },{
    //     day:'4-1',
    //     week:'周一',
    //     num:'20'
    // },{
    //     day:'4-1',
    //     week:'周一',
    //     num:'20'
    // },{
    //     day:'4-1',
    //     week:'周一',
    //     num:'20'
    // },{
    //     day:'4-1',
    //     week:'周一',
    //     num:'20'
    // },{
    //     day:'4-1',
    //     week:'周一',
    //     num:'20'
    // },{
    //     day:'4-1',
    //     week:'周一',
    //     num:'20'
    // }]
    var employee = {};

    employee.property = {
        version:"v1.0",
        name:"employee",
        tableId:"example",
        checkAllId:"employeeCheckAll",        returnStatus:"SUCCESS",
        returnTitle:"操作成功",
        statusTitle:"请选择一条数据！",
        idFailure:"获取id失败",
        prompt:"提示",
        pleaseConfirm:"请确认！",
        wantToDelete:"您确定要删除吗?",
        sexMan:"男",
        sexWoman:"女",
        isTest:"是",
        noTest:"否",
        banned:"禁用",
        enable:"启用",
        buttonId:"employeeButtonId",
        formId:"employeeForm",
        corporateFormId:"employeeForm",

    };

    //初始化配置
    employee.gridInit = {
        searching:true,
        lengthChange:true,
        paging:false,
        scrollCollapse:true,
        serverSide:false,
        search:false,
        processing:false,
        scrollY:500,
        scrollX:"100%",
        scrollXInner:"100%",
        scrollCollapse:true,
        jQueryUI:false,
        autoWidth:true,
        autoSearch:false
    };

    //路径配置
    employee.url="/";
    employee.requestUrl = {
//        路径错误
        queryList:"objects.txt"
    };

    employee.search={
        uuid:""
    };

    employee.status = [
        {"searchable": false, "orderable": false, "targets": 0},//第一行不进行排序和搜索
//        {"targets": [12], "visible": false},    //设置第13列隐藏/显示
//        {"width": "10%", "targets": [1]},  //设置第2列宽度
//        {
//            对第7列内容进行替换处理
//            targets: 6,
//            render: function (data, type, row, meta) {
//                if (data == "1") {
//                    return employee.table.sexMan;
//                }
//                if (data == "0") {
//                    return employee.table.sexWoman;
//                }
//            }
//        },
        {defaultContent: '',targets: ['_all']} //所有列设置默认值为空字符串
    ];

    employee.filed =[

        { "data": '',
            "createdCell": function (nTd, sData, oData, iRow, iCol) {
                jQuery(nTd).html("<input type='checkbox' name='checkList' value='" + sData + "'>");
            }
        },
        {
            'data' : null,
            'targets' : 0,
            "orderable": false,
            render : function(data, type, row, meta) {
                // console.log(meta)
                // 显示行号
                var startIndex = meta.settings._iDisplayStart;
                return startIndex + meta.row + 1;
            }
        },
        {"data": "name","orderable": false, },
        {"data": "position","orderable": false, },
        {"data": "salary","orderable": false, },
        {"data": "start_date","orderable": false,},
        {"data": "office","orderable": false,},
        {"data": "extn","orderable": false, },
        {"data": "start_date","orderable": false,},
        {"data": "office","orderable": false,},
        {"data": "extn","orderable": false, }
    ];





    <!--<script>-->

    var eloancn = {};

    eloancn.table={
        grid:"",
        statusTitle:"请选择一条数据！"
    };

    //dataTables方法封装
    function dataTablesInit(elo){

        eloancn.table.grid = jQuery('#'+elo.property.tableId).DataTable({
            ajax: {
                url: elo.requestUrl.queryList,//请求后台路径
                type: 'POST',
//                data: elo.search,
                error: function(jqXHR, textStatus, errorMsg){
                    alert("请求失败");
                },


            },
            "searching":elo.gridInit.searching,//搜索框，默认是开启
            "lengthChange": elo.gridInit.lengthChange,//是否允许用户改变表格每页显示的记录数，默认是开启
            "paging": elo.gridInit.paging,//是否开启本地分页，默认是开启
            "processing": elo.gridInit.processing,//是否显示中文提示
            "scrollCollapse" : elo.gridInit.scrollCollapse,  //是否开启DataTables的高度自适应，当数据条数不够分页数据条数的时候，插件高度是否随数据条数而改变
            "serverSide": elo.gridInit.serverSide, //开启服务器模式，默认是关闭
            "scrollY": elo.gridInit.scrollY,//设置高
            "scrollX": elo.gridInit.scrollX,//设置宽度
            "scrollXInner": elo.gridInit.scrollXInner,//设置内宽度
            "scrollCollapse": elo.gridInit.scrollCollapse,//设置折叠
            "jQueryUI": elo.gridInit.jQueryUI,//jquery 风格
            "autoWidth" : elo.gridInit.autoWidth, //是否自适应宽度
            "columns":elo.filed,//字段
            "columnDefs":elo.status,//列表状态
            "language": {
                "sProcessing": "处理中...",
                "sLengthMenu": "显示 _MENU_ 项结果",
                "sZeroRecords": "没有匹配结果",
                // "sInfo": "显示第 _START_ 至 _END_ 项结果，共 _TOTAL_ 项",
                // "sInfoEmpty": "显示第 0 至 0 项结果，共 0 项",
                "sInfoFiltered": "(由 _MAX_ 项结果过滤)",
                "sInfoPostFix": "",
                "sSearch": "搜索:",
                "sUrl": "",
                "sEmptyTable": "未搜索到数据",
                "sLoadingRecords": "载入中...",
                "sInfoThousands": ",",
                "oPaginate": {
                    "sFirst": "首页",
                    "sPrevious": "上页",
                    "sNext": "下页",
                    "sLast": "末页"
                },
                "oAria": {
                    "sSortAscending": ": 以升序排列此列",
                    "sSortDescending": ": 以降序排列此列"
                },
            },
            "dom": "<'row'<'col-sm-2'l><'#"+elo.property.buttonId+".col-sm-10'><'col-sm-6'f>r>t<'row'<'col-sm-6'i><'col-sm-6'p>>",
            "initComplete":function(){
                jQuery("#"+elo.property.buttonId).append(elo.buttons);
                if(elo.gridInit.search){
                    jQuerysearch = jQuery("input[type='search']");
                    //隐藏默认的搜索框
                    jQuerysearch.parent().hide();
                }
                //加载完成之后 初始化checkbox
                checkbox(elo.property.tableId);





                //checkbox全选
                jQuery("#"+elo.property.checkAllId).click(function () {
                    if (jQuery(this).prop("checked")) {
                        jQuery("input[name='checkList']").prop("checked",true);
                        jQuery("tr").addClass('selected');
                    } else {
                        jQuery("input[name='checkList']").prop("checked",false);
                        jQuery("tr").removeClass('selected');
                    }
                });

            }
        });

        // //错误信息提示
        // jQuery.fn.dataTable.ext.errMode = function(s,h,m){
        //     if(h==1){
        //         alert("连接服务器失败！");
        //     }else if(h==7){
        //         alert("返回数据错误！");
        //     }
        // };
        //
        // //回调，如果返回的时候有问题提示信息
        // eloancn.table.grid.on('xhr.dt', function ( e, settings, json, xhr ) {
        //     console.log("重新加载了数据");
        //     if(typeof(json.code)!="undefined"	&&	json.code!="0"){
        //         alert(json.message);
        //     }
        // } );

        //鼠标经过高亮
        var lastIdx = null;
        eloancn.table.grid.on( 'mouseover', 'td', function () {

            if(typeof(eloancn.table.grid.cell(this).index())!="undefined"){
                var colIdx = eloancn.table.grid.cell(this).index().column;
                if ( colIdx !== lastIdx ) {
                    jQuery( eloancn.table.grid.cells().nodes() ).removeClass( 'highlight' );
                    jQuery( eloancn.table.grid.column( colIdx ).nodes() ).addClass( 'highlight' );
                }
            }
        } );

        eloancn.table.grid.on( 'mouseleave', function () {
            jQuery(eloancn.table.grid.cells().nodes()).removeClass( 'highlight' );
        } );



        //自动搜索方法
        jQuery('.form-controlSearch').on('keyup change', function () {
            elo.gridInit.autoSearch = jQuery("#autoSearch").prop("checked");
            if(elo.gridInit.autoSearch){
                filterColumn( jQuery(this).attr('data-column') );
            }
        } );
    }

    //选中一行 checkbox选中
    function checkbox(tableId){
        //每次加载时都先清理
        jQuery('#'+tableId+' tbody').off("click","tr");
        jQuery('#'+tableId+' tbody').on("click", "tr", function () {
            jQuery(this).toggleClass('selected');
            if(jQuery(this).hasClass("selected")){
                jQuery(this).find("input").prop("checked",true);
            }else{
                jQuery(this).find("input").prop("checked",false);
            }
        });


    }

    //按钮搜索方法
    function search(){

        var oSettings = "";
        jQuery("[data-column]").each(function(){
            var filedValue = jQuery(this).attr('data-column');
            if(filedValue!=""){
                // console.log($('#col'+filedValue+'_filter').val());
                oSettings = eloancn.table.grid.column(filedValue).search(
                    jQuery('#col'+filedValue+'_filter').val()
                );
            }
        });
        //搜索的数据一次条件，节省资源
        eloancn.table.grid.draw(oSettings);
    }

    //搜索
    function filterColumn(i) {

        eloancn.table.grid.column(i).search(
            jQuery('#col'+i+'_filter').val()
        ).draw();
    }

    //清理搜索数据
    function clearSearch(id){

        jQuery("."+id).each(function(){
            jQuery(this).val("");
        });
        //清空查询条件重新读取数据
        eloancn.table.grid.columns().search("").draw();
    }

    //获取所有选中行的UUID
    function batchIds(){

        var uuid = '';
        var uuids =eloancn.table.grid.rows(".selected").data();
        if(uuids.length==0){
            alert(eloancn.table.statusTitle);
        }else{
            for(var i=0;i<uuids.length;i++){
                uuid = uuid+uuids[i].extn+",";
            }
            alert(uuid);
        }
    }

    //单选
    function selection(){

        if (eloancn.table.grid.rows(".selected").data().length==1) {
            var uuid =eloancn.table.grid.row(".selected").data().extn;

            if(uuid==""){
                alert(eloancn.table.statusTitle);
            }else{
                alert(uuid);
            }

        }else{
            alert(eloancn.table.statusTitle);
        }
    }

    //刷新页面
    //重新加载数据
    function reload(){
        eloancn.table.grid.ajax.reload();
    }

    //销毁table
    function destroyDataTable(tableId){

        var dttable =  jQuery('#'+tableId).DataTable();
        dttable.destroy();
    }




    <!--<script>-->
    // function m() {

        $('table').on('click','tr',function (e) {
        // console.log(e)
        console.log(e.currentTarget.children[1].innerText)
            $scope.s=e.currentTarget.children[1].innerText

       })
       $('.rili').on('click','.dp-item',function (e) {
        // console.log(e)
        console.log($('.dp-selected').innerText)
        $scope.s=e.currentTarget.innerText

    })
    $('.fenzu-ul').on('click','div',function (e) {
        console.log(e)
        $scope.s=e.currentTarget.children[1].innerText

    })
    console.log($scope.s)
    //     return s
    // }
    // m()
    // 时间块适应
    $scope.selecte=-1
    $scope.selected=function ($index) {
        // console.log($event.target)
        if($scope.selecte!=$index){
            $scope.selecte=$index
        }else{
            $scope.selecte=-1;
        }
    };
    $scope.fenzus=[{
        id:1
    },{
        id:2
    },{
        id:3
    },{
        id:4
    }];
    $scope.choosed=-1;
    $scope.choose=function ($index) {
        $scope.choosed=$scope.choosed!=$index?$index:-1;
    };
    // 分组显引
    $scope.showings=true;
    setTimeout(function () {
        dataTablesInit(employee);
    });
    // jQuery(document).ready(function(){
    //     dataTablesInit(employee);
    // });
    // 全部选项默认选中
    $scope.ones=true;
    var date=new Date();
    var fdata=new Date(date.getTime() - 24*60*60*1000*15);
    console.log(date);
    var formatDate = function (date) {
        var y = date.getFullYear();
        var m = date.getMonth() + 1;
        m = m < 10 ? '0' + m : m;
        var d = date.getDate();
        d = d < 10 ? ('0' + d) : d;
        return y + '-' + m + '-' + d;
    }
    var data=formatDate(date)
    console.log(data)
    var fdate=formatDate(fdata)
    jQuery(function() {
        var options = {
            selectedDate: data,
            showOffDays: false,
            showStartOfWeek:false,
            itemWidth: 105,
            startDate:fdate,endDate:'2017-11-7',
            language: 'cn',
            // onSelectedDateChanged: function(event, date) {
            //     // Your logic goes here
            //     alert('...')
            // }
            // size:'large'
        }
        // $('#paginator').datepaginator();
        jQuery('#paginator-start-end').datepaginator(options);
        // $('#paginator-start-end').datepaginator({selectedDate:data,
        //     startDate:data,endDate:'2017-11-7'});
    });
    $scope.fenzu=[{
        num:5,
        time:'8:00',
        all:20
    },{
        num:5,
        time:'8:00',
        all:20
    },{
        num:5,
        time:'8:00',
        all:20
    },{
        num:5,
        time:'8:00',
        all:20
    },{
        num:5,
        time:'8:00',
        all:20
    },{
        num:5,
        time:'8:00',
        all:20
    },{
        num:20,
        time:'8:00',
        all:20
    }]
    var ss=$scope.fenzu.length
    // var s=ss%2
    // $scope.m=s==0?ss/2:math.ceil(ss/2)
    // console.log($scope.m)
    $scope.mm=Math.floor(24/ss)
    console.log($scope.mm)
});


